package collection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class GenericDemo {
    public static void main(String[] args) {
//        Collection<String> c =new ArrayList<>();
//        c.add("one");
//        c.add("two");
//        c.add("three");
//        c.add("four");
//        c.add("five");
//        Iterator<String> ite=c.iterator();
//        while(ite.hasNext()){
//            System.out.print(ite.next()+ " ");
//        }
//        System.out.println();
//
//        for(String str: c){
//            System.out.print(str+" ");
//        }

//        Collection co=new ArrayList<>();
        Collection<Point> c=new ArrayList<>();
        c.add(new Point(1,2));
        c.add(new Point(3,4));
        c.add(new Point(5,6));
        c.add(new Point(7,8));

        Iterator<Point> ite=c.iterator();
        while (ite.hasNext()) {
            Point point=ite.next();
            System.out.print(point+" ");
        }
        System.out.println();
        for(Point p: c){
            System.out.print(p+" ");
        }

    }
}
